GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 3002d9...0b2563 )
by Florian
01:10
created

line.js ➔ Line   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 34

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 34
rs 8.8571
1
/*jslint
2
  regexp: true
3
  indent: 4
4
*/
5
6
/*global
7
  $, google,
8
  Coordinates, Markers, TxtOverlay,
9
  id2alpha
10
*/
11
12
function Line(themap, id, source, target) {
13
    'use strict';
14
15
    this.m_map = themap;
16
    this.m_id = id;
17
    this.m_lineMapObject = null;
18
    this.m_source = -1;
19
    this.m_target = -1;
20
    this.m_distanceLabel = null;
21
22
    $('#dynLineDiv').append(
23
        "<div id=\"dynLine" + id + "\">" +
24
            "<table style=\"width: 100%\">" +
25
            "<tr>" +
26
            "<td>" +
27
            "<select id=\"dynlinesource" + id + "\" class=\"my-small-select\" data-i18n=\"[title]sidebar.lines.source\" onchange=\"Lines.selectLineSource(" + id + ")\"><option value=\"-1\">?</option></select>" +
28
            "&nbsp;&rarr;&nbsp;" +
29
            "<select id=\"dynlinetarget" + id + "\" class=\"my-small-select\" data-i18n=\"[title]sidebar.lines.destination\" onchange=\"Lines.selectLineTarget(" + id + ")\"><option value=\"-1\">?</option></select>" +
30
            "</td>" +
31
            "<td>" +
32
            "<button class=\"my-button btn btn-mini btn-danger\" style=\"float: right\" data-i18n=\"[title]sidebar.lines.delete_line\" type=\"button\" onClick=\"trackLine('delete'); Lines.deleteLine(" + id + ")\"><i class=\"fa fa-trash-o\"></i></button>" +
33
            "<div>" +
34
            "</div>" +
35
            "</td>" +
36
            "</tr>" +
37
            "<tr><td colspan=\"2\"><i class=\"fa fa-arrows-h\"></i> <span id=\"dynlinedist" + id + "\">n/a</span> <i class=\"fa fa-compass\"></i> <span id=\"dynlineangle" + id + "\">n/a</span></td></tr>" +
38
            "</table>" +
39
            "</div>"
40
    );
41
42
    this.updateLists();
43
    this.setSource(source);
44
    this.setTarget(target);
45
}
46
47
48
Line.prototype.m_map = null;
49
Line.prototype.m_id = -1;
50
Line.prototype.m_lineMapObject = null;
51
Line.prototype.m_source = -1;
52
Line.prototype.m_target = -1;
53
Line.prototype.m_distanceLabel = null;
54
55
56
Line.prototype.getId = function () {
57
    'use strict';
58
59
    return this.m_id;
60
};
61
62
63
Line.prototype.clearMapObject = function () {
64
    'use strict';
65
66
    if (this.m_lineMapObject) {
67
        this.m_lineMapObject.setMap(null);
68
        this.m_lineMapObject = null;
69
    }
70
71
    if (this.m_distanceLabel) {
72
        this.m_distanceLabel.setMap(null);
73
        this.m_distanceLabel = null;
74
    }
75
};
76
77
78
Line.prototype.updateMapObject = function (pos1, pos2, center) {
79
    'use strict';
80
81
    if (!this.m_lineMapObject) {
82
        this.m_lineMapObject = new google.maps.Polyline({
83
            strokeColor: '#ff0000',
84
            strokeWeight: 2,
85
            strokeOpacity: 0.7,
86
            geodesic: true,
87
            icons: [{
88
                icon: {
89
                    path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW
90
                },
91
                repeat: '0'
92
            }]
93
        });
94
        this.m_lineMapObject.setMap(this.m_map);
95
        this.m_distanceLabel = new TxtOverlay(center, "n/a", "mapDistanceLabel", this.m_map);
96
    }
97
98
    var path = new google.maps.MVCArray();
99
    path.push(pos1);
100
    path.push(pos2);
101
    this.m_lineMapObject.setPath(path);
102
103
    this.m_distanceLabel.setPos(center);
104
};
105
106
107
Line.prototype.getEndpointsString = function () {
108
    'use strict';
109
110
    return id2alpha(this.m_source) + ":" + id2alpha(this.m_target);
111
};
112
113
114
Line.prototype.setSource = function (markerId) {
115
    'use strict';
116
117
    if (markerId !== this.m_source) {
118
        this.m_source = markerId;
119
        this.update();
120
        $("#dynlinesource" + this.m_id + " > option[value=" + markerId + "]").attr("selected", "selected");
121
    }
122
};
123
124
125
Line.prototype.setTarget = function (markerId) {
126
    'use strict';
127
128
    if (markerId !== this.m_target) {
129
        this.m_target = markerId;
130
        this.update();
131
        $("#dynlinetarget" + this.m_id + " > option[value=" + markerId + "]").attr("selected", "selected");
132
    }
133
};
134
135
136
Line.prototype.update = function () {
137
    'use strict';
138
139
    if (this.m_source === -1 || this.m_target === -1) {
140
        this.clearMapObject();
141
142
        $("#dynlinedist" + this.m_id).html("n/a");
143
        $("#dynlineangle" + this.m_id).html("n/a");
144
145
        return;
146
    }
147
148
    var pos1 = Markers.getById(this.m_source).getPosition(),
149
        pos2 = Markers.getById(this.m_target).getPosition(),
150
        dist_angle = Coordinates.dist_angle_geodesic(pos1, pos2),
151
        centerPos = Coordinates.projection_geodesic(pos1, dist_angle.angle, 0.5 * dist_angle.dist);
152
153
    this.updateMapObject(pos1, pos2, centerPos);
154
155
    if (dist_angle.dist <= 0) {
156
        this.m_distanceLabel.setText("");
157
        $("#dynlinedist" + this.m_id).html("0m");
158
        $("#dynlineangle" + this.m_id).html("n/a");
159
    } else {
160
        this.m_distanceLabel.setText(dist_angle.dist.toFixed() + "m");
161
        $("#dynlinedist" + this.m_id).html(dist_angle.dist.toFixed() + "m");
162
        $("#dynlineangle" + this.m_id).html(dist_angle.angle.toFixed(1) + "°");
163
    }
164
};
165
166
167
Line.prototype.updateMarkerMoved = function (markerId) {
168
    'use strict';
169
170
    if (this.m_source === markerId || this.m_target === markerId) {
171
        this.update();
172
    }
173
};
174
175
176
Line.prototype.updateMarkerRemoved = function (markerId) {
177
    'use strict';
178
179
    if (this.m_source === markerId) {
180
        this.m_source = -1;
181
        this.clearMapObject();
182
    }
183
184
    if (this.m_target === markerId) {
185
        this.m_target = -1;
186
        this.clearMapObject();
187
    }
188
189
    this.updateLists();
190
};
191
192
193
Line.prototype.updateMarkerAdded = function () {
194
    'use strict';
195
196
    this.updateLists();
197
};
198
199
200
Line.prototype.updateLists = function () {
201
    'use strict';
202
203
    var source = $('#dynlinesource' + this.m_id),
204
        target = $('#dynlinetarget' + this.m_id),
205
        i,
206
        m;
207
208
    source.empty();
209
    target.empty();
210
211
    source.append('<option value="-1">?</option>');
212
    target.append('<option value="-1">?</option>');
213
214
    for (i = 0; i < Markers.getSize(); i = i + 1) {
215
        m = Markers.getById(i);
216
        if (!m.isFree()) {
217
            source.append('<option value="' + i + '">' + m.getAlpha() + '</option>');
218
            target.append('<option value="' + i + '">' + m.getAlpha() + '</option>');
219
        }
220
    }
221
222
    $("#dynlinesource" + this.m_id + " > option[value=" + this.m_source + "]").attr("selected", "selected");
223
    $("#dynlinetarget" + this.m_id + " > option[value=" + this.m_target + "]").attr("selected", "selected");
224
};
225